package jmine.tec.executionlog.domain;

import java.io.InputStream;

import jmine.tec.executionlog.domain.enumx.ExecutionStatus;

import org.apache.commons.io.IOUtils;

import bancosys.tec.persist.builders.AbstractDBBuilder;
import bancosys.tec.utils.date.Date;
import bancosys.tec.utils.date.Timestamp;

public class ExecutionLogBuilder extends AbstractDBBuilder<ExecutionLog> {

    private ExecutionLog bean = createBean();

    public static ExecutionLogBuilder anExecutionLog() {
        ExecutionLogBuilder builder = new ExecutionLogBuilder();
        builder.fileCode("IMPORTACAO");
        builder.status(ExecutionStatus.RUNNING);
        builder.executionStartTime(new Timestamp());
        builder.executionEndTime(new Timestamp());
        builder.fileDate(new Date());
        builder.fileName("file.txt");
        builder.origem("internet");
        builder.totalItems(42);
        builder.userName("john.smith");
        builder.content(IOUtils.toInputStream("content"));
        return builder;
    }

    @Override
    protected ExecutionLog doBuild() {
        return bean;
    }

    public ExecutionLogBuilder fileCode(String value) {
        bean.setFileCode(value);
        return this;
    }

    public ExecutionLogBuilder fileName(String value) {
        bean.setFileName(value);
        return this;
    }

    public ExecutionLogBuilder fileDate(Date value) {
        bean.setFileDate(value);
        return this;
    }

    public ExecutionLogBuilder origem(String value) {
        bean.setOrigem(value);
        return this;
    }

    public ExecutionLogBuilder totalItems(Integer value) {
        bean.setTotalItems(value);
        return this;
    }

    public ExecutionLogBuilder executionStartTime(Timestamp value) {
        bean.setExecutionStartTime(value);
        return this;
    }

    public ExecutionLogBuilder executionEndTime(Timestamp value) {
        bean.setExecutionEndTime(value);
        return this;
    }

    public ExecutionLogBuilder content(InputStream value) {
        bean.setContent(value);
        return this;
    }

    public ExecutionLogBuilder status(ExecutionStatus value) {
        bean.setStatus(value);
        return this;
    }

    public ExecutionLogBuilder userName(String value) {
        bean.setUserName(value);
        return this;
    }
}
